package com.chinaunicom.create.singleton.hungry;

import java.util.Random;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/7/14 14:22
 * Description: 懒汉式(枚举)
 */
public enum HSingleton06 {

    INSTANCE;
    
    private HSingleton06() {
    }
    
    public void say(){
        System.out.println("hello .....");
    }
    


    public static void main(String[] args) {
        Random random = new Random();
        System.out.println(Runtime.getRuntime().totalMemory());
        for (int i = 0; i < 10; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
//                       Thread.sleep(random.nextInt(100));
                        System.out.println(HSingleton06.INSTANCE.hashCode());
                        HSingleton06.INSTANCE.say();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }, "Thread name: " + i).start();
        }

    }
}
